package cn.edu.neusoft.zengweidong707.neufood.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import cn.edu.neusoft.zengweidong707.neufood.R;
import cn.edu.neusoft.zengweidong707.neufood.bean.UserOrderBean;

/**
 * Created by Lucio on 2017/12/21.
 */

public class UserCommentAdapter extends BaseAdapter<UserOrderBean>{
    public UserCommentAdapter(Context context, List<UserOrderBean> items) {
        super(context, items);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(context)
                .inflate(R.layout.items_food_comment, parent, false);
        UserCommentViewHolder userCommentViewHolder = new UserCommentViewHolder(itemView);
        return userCommentViewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final UserOrderBean entity = (UserOrderBean) items.get(position);
        if (null == entity)
            return;
        UserCommentViewHolder myViewHolder = (UserCommentViewHolder) holder;
        myViewHolder.com_name.setText(entity.getUsername());
        myViewHolder.com_content.setText(entity.getContent());
        myViewHolder.com_time.setText(entity.getComment_time());

    }

    public static class UserCommentViewHolder extends RecyclerView.ViewHolder {
        TextView com_name;
        TextView com_content;
        TextView com_time;
        UserCommentViewHolder(View itemView) {
            super(itemView);
            com_name = (TextView) itemView.findViewById(R.id.com_name);
            com_content = (TextView) itemView.findViewById(R.id.com_content);
            com_time = (TextView) itemView.findViewById(R.id.com_time);
        }
    }
}
